import importlib

from attack.base_attack import BaseAttack

def get_attack(name, model, config):
    attack = importlib.import_module('attack.methods.' + name).Attack(model, config)
    assert isinstance(attack, BaseAttack), 'Attack class must extend attack.base_attack.BaseAttack'
    assert attack.name == name, 'Attack name must be the same as its file name'
    return attack
